#pragma once
#include <QUndoView>
#include <QUndoStack>
#include <QUndoCommand>
#include <QPalette>
#include "../elements/diagramelement.h"
#include "../elements/textelement.h"
#include "../links/controlflow.h"
#include "../links/noteanchor.h"


class MoveCommand : public QUndoCommand
{
public:
    MoveCommand(QGraphicsScene* _scene, QList<QPair<QGraphicsItem *, QPointF>> _oldPos, QUndoCommand *parent = 0);

    void undo();
    void redo();
    //bool mergeWith(const QUndoCommand *command);

private:
	QGraphicsScene* scene;
    QList<QPair<QGraphicsItem *, QPointF>> oldPos;
	QList<QPair<QGraphicsItem *, QPointF>> newPos;
};






class DeleteCommand : public QUndoCommand
{
public:
    DeleteCommand(QGraphicsScene *graphicsScene, QList<QGraphicsItem*> _list, QUndoCommand *parent = 0);

    void undo();
    void redo();

private:
    QList<DiagramElement*> elements;
	QList<Link*> links;
    QGraphicsScene* scene;
    QList<QPointF> pos;
};






class AddCommand : public QUndoCommand
{
public:
	AddCommand(QGraphicsScene* _scene, QList<QGraphicsItem*> _list, QUndoCommand *_parent=0);
    ~AddCommand();

    void undo();
    void redo();
	
private:
    QList<DiagramElement*> elements;
	QList<Link*> links;
    QGraphicsScene* scene;
    QList<QPointF> pos;
};

class EditTextCommand : public QUndoCommand
{
public:
	EditTextCommand(QGraphicsItem* _element, QString _oldText, QUndoCommand *_parent=0);
    ~EditTextCommand();

    void undo();
    void redo();

private:
    TextElement* element;
	QString oldText;
	QString newText;
};




QString elementToStr(DiagramElement* de);